#include "headfile.h"
#include "get_adc.h"

void adc_get_init(void)
{ 
  adc_init(ADC_2,ADC2_CH4_B20,ADC_8BIT);
  adc_init(ADC_1,ADC1_CH4_B19,ADC_8BIT);
  adc_init(ADC_2,ADC2_CH3_B18,ADC_8BIT);
  adc_init(ADC_1,ADC1_CH3_B17,ADC_8BIT);
  adc_init(ADC_1,ADC1_CH1_B14,ADC_8BIT);

}

uint16 adc[32]={0};
uint16 bva[32]={0};
void adc_get(void)
{
  adc[0] = adc_mean_filter(ADC_2,ADC2_CH4_B20,10);
  adc[1] = adc_mean_filter(ADC_2,ADC2_CH3_B18,10);
//  adc[2] = adc_mean_filter(ADC_2,ADC2_CH3_B18,10);
//  adc[3] = adc_mean_filter(ADC_1,ADC1_CH3_B17,10);
//  adc[4] = adc_mean_filter(ADC_1,ADC1_CH1_B14,10);
  
  bva[0] = adc[0]*(-0.85) + 164.05;
  bva[0] = limit_ab(bva[0],0,100);
  
  bva[1] = adc[1]*(-0.85) + 164.05; 
  bva[1] = limit_ab(bva[1],0,100);
}



//0    100
//773  305
//193  76